<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>表格查询</title>
    <#assign base=request.contextPath  />
    <base id="base" href="${base}">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, adminUser-scalable=0">
    <link rel="stylesheet" href="${base}/static/win10/component/layui/css/layui.css" media="all">
    <script>
        var base =  "${base}";
    </script>
</head>
<body>
<br>


<div class="demoTable" style="margin-left: 15px;">
    <form class="layui-form " action="" >
    <div class="layui-form-item">
        <label>企业名字</label>
        <div class="layui-inline">
            <input class="layui-input" name="companyName" id="companyName" autocomplete="off">
        </div>
       <#-- <label>企业资质验证</label>
        <div class="layui-inline">
            <input class="layui-input" name="companyQualification" id="companyQualification" autocomplete="off">
        </div>
        <label>营业执照图片</label>
        <div class="layui-inline">
            <input class="layui-input" name="companyLicenseImg" id="companyLicenseImg" autocomplete="off">
        </div>
        <label>关联用户的ID</label>
        <div class="layui-inline">
            <input class="layui-input" name="userId" id="userId" autocomplete="off">
        </div>
        <label>创建时间</label>
        <div class="layui-inline">
            <input class="layui-input" name="companyCreateTime" id="companyCreateTime" autocomplete="off">
        </div>
        <label>修改时间</label>
        <div class="layui-inline">
            <input class="layui-input" name="companyUpdateTime" id="companyUpdateTime" autocomplete="off">
        </div>
        <label>是否删除 0正常 / 1已删除</label>
        <div class="layui-inline">
            <input class="layui-input" name="companyIsDelete" id="companyIsDelete" autocomplete="off">
        </div>
        <label>企业备注</label>
        <div class="layui-inline">
            <input class="layui-input" name="companyRemarks" id="companyRemarks" autocomplete="off">
        </div>
        <label>企业区域ID </label>
        <div class="layui-inline">
            <input class="layui-input" name="areaId" id="areaId" autocomplete="off">
        </div>
        <label>企业规模</label>
        <div class="layui-inline">
            <input class="layui-input" name="companyScale" id="companyScale" autocomplete="off">
        </div>
        <label>企业Logo</label>
        <div class="layui-inline">
            <input class="layui-input" name="companyLogo" id="companyLogo" autocomplete="off">
        </div>-->
        <button type="button" class="layui-btn" data-type="reload">
            <i class="layui-icon layui-icon-search">搜索</i>
        </button>
    </div>
    </form>
</div>
<table class="layui-hide" id="test" lay-filter="test"></table>
<script type="text/html" id="toolbarDemo">


    <form class="layui-form " action="">
        <div class="layui-form-item" style="margin-left: 15px;">
            <div class="layui-btn-group">
                <button type="button" class="layui-btn" lay-event="add">增加</button>
                <button type="button" class="layui-btn" lay-event="edit">编辑</button>
                <button type="button" class="layui-btn" lay-event="show">查看</button>
                <button type="button" class="layui-btn" lay-event="del">删除</button>
            </div>
        </div>

    </form>
</script>

<script src="${base}/static/win10/component/layui/layui.js?t=1"></script>
<script src="${base}/static/win10/js/jquery-1.8.3.min.js?t=1"></script>
<script>
    layui.use(['table'], function () {
        var table = layui.table;
        table.render({
            skin: 'line' //行边框风格
            , even: true //开启隔行背景
            , elem: '#test'
            , url: base + '/WeChatUser/wechatCompany/admin/findWechatCompanyByPage'
            , toolbar: '#toolbarDemo'
            , cols: [[
                {type: 'radio'},
                  {field: 'companyId', title: '企业ID'},
                  {field: 'companyName', title: '企业名字'},
                  {field: 'companyQualification', title: '企业资质验证'},
                  {field: 'companyLicenseImg', title: '营业执照图片'},
                  {field: 'userId', title: '关联用户的ID'},
                  {field: 'companyCreateTime', title: '创建时间'},
                  {field: 'companyUpdateTime', title: '修改时间'},
                  {field: 'companyIsDelete', title: '是否删除 0正常 / 1已删除'},
                  {field: 'companyRemarks', title: '企业备注'},
                  {field: 'areaId', title: '企业区域ID '},
                  {field: 'companyScale', title: '企业规模'},
                      {field: 'companyLogo', title: '企业Logo'}
            ]]
            , page: true
            , id: 'testReload'
        });
        //搜索
        var $ = layui.$, active = {
            reload: function(){
                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                                    companyName:$("#companyName").val(),
                                    companyQualification:$("#companyQualification").val(),
                                    companyLicenseImg:$("#companyLicenseImg").val(),
                                    userId:$("#userId").val(),
                                    companyCreateTime:$("#companyCreateTime").val(),
                                    companyUpdateTime:$("#companyUpdateTime").val(),
                                    companyIsDelete:$("#companyIsDelete").val(),
                                    companyRemarks:$("#companyRemarks").val(),
                                    areaId:$("#areaId").val(),
                                    companyScale:$("#companyScale").val(),
                                    companyLogo:$("#companyLogo").val()
                    }
                }, 'data');
            }
        };
        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        //头工具栏事件
        table.on('toolbar(test)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id); //获取选中行状态
            var data = checkStatus.data;  //获取选中行数据
            switch (obj.event) {
                case 'add':
                    //请继续补充以下逻辑
                    window.location.href=base+"/WeChatUser/wechatCompany/admin/addWechatCompanyHtml"
                    break;
                case 'edit':
                    if (data.length === 0) {
                        layer.alert("请选择一条数据")
                        return;
                    }
                    //请继续补充以下逻辑
                    window.location.href=base+"/WeChatUser/wechatCompany/admin/editWechatCompanyHtml?id=" + data[0].companyId
                    break;
                case 'show':
                    if (data.length === 0) {
                        layer.alert("请选择一条数据")
                        return;
                    }
                    //请继续补充以下逻辑
                    window.location.href=base+"/WeChatUser/wechatCompany/admin/showWechatCompanyHtml?id=" + data[0].companyId
                    break;
                case 'del':
                    if (data.length === 0) {
                        layer.alert("请选择一条数据")
                        return;
                    }
                    layer.confirm('真的要删除吗?',function(index){
                        $.ajax({
                            type:"POST",
                            url:base+'/WeChatUser/wechatCompany/admin/delWechatCompany',
                            data:{"id":data[0].companyId},
                            success:function(data){
                                if(data.code===200){
                                    layer.msg(data.message)
                                    setTimeout(function () {
                                        window.location.reload();
                                    }, 500)
                                }else{
                                    layer.msg(data.message)
                                }
                            }
                        });
                    });
                    break;
            };
        });
    })
</script>
</body>
</html>